home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: April 17, 1997
- // Author: mgr
- //
- // Description:
- // The doAttachCurveArgList() procedure executes an attach curve operation
- // on a pair of curves based on the attach option vars. In general
- // if you have n curves selected, only the last 2 curves would
- // be attached.
- //
- // Versions:
- // "1" is Maya V1, Maya V1.5
- // "2" is Maya V2.
- //
-
- proc string pieceTogetherAttachCmd( string $version, string $args[] )
- //
- // Description :
- // Piece together an attach command.
- //
- {
- string $cmd = "";
- int $need = 0;
-
- if( "1" == $version ) {
- $need = 3;
- }
- else if( "2" == $version ) {
- $need = 7;
- }
- else {
- warning( "Bad version for doAttachCurveArgList. Using 1." );
- $version = "1";
- $need = 3;
- }
-
- if( size($args) < $need ) {
- error( "Not enough arguments to doAttachCurveArgList" );
- return $cmd;
- }
-
- $cmd = "attachCurve ";
-
- // construction history
- $cmd = $cmd + " -ch " + $args[0];
- $cmd = $cmd + " -rpo " + $args[1];
- $cmd = $cmd + " -kmk " + $args[2];
-
- if( "2" == $version ) {
- $cmd = $cmd + " -m " + $args[3];
- $cmd = $cmd + " -bb " + $args[4];
- $cmd = $cmd + " -bki " + $args[5];
- $cmd = $cmd + " -p " + $args[6];
- }
-
- return $cmd;
- }
-
- global proc doAttachCurveArgList( string $version, string $args[] )
-
- //
- // attach with the preset options.
- // Use this proc when operation dragged to Shelf.
- //
- {
- string $cmd = pieceTogetherAttachCmd( $version, $args );
- if( "" == $cmd ) return;
-
- int $history = $args[0];
- int $replaceOriginal = $args[1];
-
- int $nitems = 2;
- $cmd = appendToCmdPlaceHoldersForSelectionItems( $cmd, $nitems );
-
- // Get the list of nurbs curves selected.
- //
- global int $gSelectNurbsCurvesBit;
- global int $gSelectCurvesOnSurfacesBit;
- global int $gSelectCurveParmPointsBit;
- string $curvesList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit -sm $gSelectCurvesOnSurfacesBit -sm $gSelectCurveParmPointsBit`;
-
- int $numCurves = size($curvesList);
- if ( $numCurves == 0 )
- {
- error("No curves selected to attach. You must select pairs of curves.");
- }
- else if ( $numCurves == 1 )
- {
- error("Not enough curves selected to attach. You must select pairs of curves.");
- }
- else if ( $numCurves > 1 )
- {
- // just use the last 2 selected curves
- //
- if ( $numCurves > 2 )
- warning("Only 2 curves should be selected to attach. The last 2 selected curves will be used.");
-
- string $attachPair[2];
- $attachPair[0] = $curvesList[$numCurves-2];
- $attachPair[1] = $curvesList[$numCurves-1];
-
- if ( $history == 0 && $replaceOriginal == 1 )
- {
- // delete history on each input to attach cmd (so that command
- // won't force history on)
- //
- string $buffer[];
- tokenize($attachPair[0], ".", $buffer);
- string $curveName = $buffer[0];
- $buffer = `listHistory -pdo 1 $curveName`;
- if ( size($buffer) > 0 )
- {
- // the first curve has history so delete it
- //
- warning("History will be deleted on first curve for attach.");
- evalEcho("delete -ch " + $curveName);
- }
-
- tokenize($attachPair[1], ".", $buffer);
- $curveName = $buffer[0];
- $buffer = `listHistory -pdo 1 $curveName`;
- if ( size($buffer) > 0 )
- {
- // the second curve has history so delete it
- //
- warning("History will be deleted on second curve for attach.");
- evalEcho("delete -ch " + $curveName);
- }
- }
-
- string $results[] = executeCmdOnItems( $cmd, $attachPair );
-
- // select the results.
- //
- int $resultCount = size($results);
- if ( $resultCount > 0 )
- {
- string $selectString;
- $selectString = "select ";
- if ( $replaceOriginal )
- {
- if ( $history == 0 )
- {
- // delete the second curve since it is no longer required
- evalEcho("delete " + $results[1]);
- }
- else
- {
- // make the second curve an intermediate object (so that
- // the user won't ever see it). Note: can't do "delete"
- // here or else attach result will go away due to history
- // on.
- //
- string $resultShapes[] = `listRelatives -s $results[1]`;
- int $shapeCount = size($resultShapes);
- if ( $shapeCount > 0 )
- {
- evalEcho("setAttr " + $resultShapes[0] + ".io true");
- }
- }
- $selectString += $results[0];
- }
- else
- {
- int $i;
- for ( $i = 0; $i < $resultCount; $i++ )
- {
- $selectString += $results[$i];
- $selectString += " ";
- }
- }
- $selectString += ";";
- select -cl;
- eval($selectString);
- }
- }
- }
-